/**
 * Created by liujinghao on 12/14 0014.
 *
 */

var allData = {
    "citys": [{
        "name": "延寿",
        "value": [128.331644, 45.451897, 2],
        "symbolSize": 20,
        "itemStyle": {"normal": {"color": "#F58158"}}
    }, {
        "name": "阳泉",
        "value": [113.580519, 37.856972, 1],
        "symbolSize": 2,
        "itemStyle": {"normal": {"color": "#F58158"}}
    }, {
        "name": "勃利",
        "value": [130.592171, 45.755063, 1],
        "symbolSize": 2,
        "itemStyle": {"normal": {"color": "#F58158"}}
    }, {
        "name": "长春",
        "value": [125.323544, 43.817072, 8],
        "symbolSize": 2,
        "itemStyle": {"normal": {"color": "#F58158"}}
    }],
    "moveLines": [{
        "fromName": "黑龙江",
        "toName": "珠海",
        "coords": [[126.661669, 45.742347], [113.576726, 22.270715]]
    }, {
        "fromName": "河北",
        "toName": "哈尔滨",
        "coords": [[114.475704, 38.584854], [126.534967, 45.803775]]
    }, {
        "fromName": "黑龙江",
        "toName": "江苏",
        "coords": [[126.661669, 45.742347], [118.763232, 32.061707]]
    }, {
        "fromName": "吉林",
        "toName": "和平",
        "coords": [[126.549572, 43.837883], [117.21451, 39.116949]]
    }, {
        "fromName": "江苏",
        "toName": "鸡东",
        "coords": [[118.763232, 32.061707], [131.12408, 45.260412]]
    }, {
        "fromName": "辽宁",
        "toName": "辉南",
        "coords": [[123.42944, 41.835441], [126.046912, 42.684993]]
    }, {
        "fromName": "吉林",
        "toName": "深圳",
        "coords": [[126.549572, 43.837883], [114.057868, 22.543099]]
    }, {
        "fromName": "福建",
        "toName": "泰顺",
        "coords": [[119.295144, 26.10078], [119.717649, 27.556884]]
    }, {
        "fromName": "上海",
        "toName": "深圳",
        "coords": [[121.473701, 31.230416], [114.057868, 22.543099]]
    }, {
        "fromName": "吉林",
        "toName": "秦皇岛",
        "coords": [[126.549572, 43.837883], [119.600493, 39.935385]]
    }, {
        "fromName": "吉林",
        "toName": "徐汇",
        "coords": [[126.549572, 43.837883], [121.436525, 31.188523]]
    }, {
        "fromName": "吉林",
        "toName": "石景山",
        "coords": [[126.549572, 43.837883], [116.222982, 39.906611]]
    }, {
        "fromName": "辽宁",
        "toName": "城阳",
        "coords": [[123.42944, 41.835441], [120.39631, 36.307064]]
    }, {
        "fromName": "黑龙江",
        "toName": "威海",
        "coords": [[126.661669, 45.742347], [122.12042, 37.513068]]
    }, {
        "fromName": "黑龙江",
        "toName": "惠州",
        "coords": [[126.661669, 45.742347], [114.416196, 23.111847]]
    }, {
        "fromName": "吉林",
        "toName": "龙口",
        "coords": [[126.549572, 43.837883], [120.477813, 37.646108]]
    }, {
        "fromName": "黑龙江",
        "toName": "四平",
        "coords": [[126.661669, 45.742347], [124.350398, 43.16642]]
    }, {
        "fromName": "吉林",
        "toName": "南充",
        "coords": [[126.549572, 43.837883], [106.110698, 30.837793]]
    }, {
        "fromName": "河北",
        "toName": "东港",
        "coords": [[114.475704, 38.584854], [124.152705, 39.863008]]
    }, {
        "fromName": "辽宁",
        "toName": "西安",
        "coords": [[123.42944, 41.835441], [108.940175, 34.341568]]
    }, {
        "fromName": "内蒙古",
        "toName": "滨海",
        "coords": [[111.765618, 40.817498], [119.820831, 33.990334]]
    }, {
        "fromName": "河南",
        "toName": "青岛",
        "coords": [[113.274379, 34.445122], [120.38264, 36.067082]]
    }, {
        "fromName": "黑龙江",
        "toName": "昆山",
        "coords": [[126.661669, 45.742347], [120.980737, 31.385598]]
    }, {
        "fromName": "辽宁",
        "toName": "长沙",
        "coords": [[123.42944, 41.835441], [112.938814, 28.228209]]
    }, {
        "fromName": "吉林",
        "toName": "哈尔滨",
        "coords": [[126.549572, 43.837883], [126.534967, 45.803775]]
    }, {
        "fromName": "河北",
        "toName": "尚志",
        "coords": [[114.475704, 38.584854], [128.009895, 45.209586]]
    }, {
        "fromName": "辽宁",
        "toName": "东城",
        "coords": [[123.42944, 41.835441], [116.416357, 39.928353]]
    }, {
        "fromName": "辽宁",
        "toName": "珠海",
        "coords": [[123.42944, 41.835441], [113.576726, 22.270715]]
    }, {
        "fromName": "黑龙江",
        "toName": "铁岭",
        "coords": [[126.661669, 45.742347], [123.726166, 42.223769]]
    }, {
        "fromName": "黑龙江",
        "toName": "蓬莱",
        "coords": [[126.661669, 45.742347], [120.758848, 37.810661]]
    }, {
        "fromName": "北京",
        "toName": "天津",
        "coords": [[116.407526, 39.90403], [117.200983, 39.084158]]
    }, {
        "fromName": "内蒙古",
        "toName": "天津",
        "coords": [[111.765618, 40.817498], [117.200983, 39.084158]]
    }, {
        "fromName": "河北",
        "toName": "齐齐哈尔",
        "coords": [[114.475704, 38.584854], [126.661669, 45.742347]]
    }, {
        "fromName": "吉林",
        "toName": "中山",
        "coords": [[126.549572, 43.837883], [113.392782, 22.517646]]
    }, {"fromName": "黑龙江", "toName": "胶州", "coords": [[126.661669, 45.742347], [120.033382, 36.26468]]}]
};

function mapOptionCalc() {
    option_china = {
        tooltip: {
            show: true,
            "formatter": function (params) {
                var obj = JSON.parse(JSON.stringify(params));
                var str = obj.name + ":" + obj.data.value[2];
                return str;
            }
        },
        geo: {
            map: 'china',
            label: {
                emphasis: {
                    show: false
                }
            },
            roam: false,
            itemStyle: {
                normal: {
                    areaColor: 'rgba(0,0,0,0.7)',
                    borderColor: '#fff'
                },
                emphasis: {
                    areaColor: 'rgba(0,0,0,0.7)'
                }
            }
        },
        series: [{
            name: '地点',
            type: 'effectScatter',
            coordinateSystem: 'geo',
            zlevel: 2,
            rippleEffect: {
                brushType: 'stroke'
            },
 
            symbolSize: 2,
            showEffectOn: 'render',
            itemStyle: {
                normal: {
                    color: '#46bee9'
                }
            },
            data: allData.citys
        }, {
            name: '线路',
            type: 'lines',
            coordinateSystem: 'geo',
            zlevel: 2,
            large: true,
            effect: {
                show: true,
                constantSpeed: 80,
                symbol: 'spot',
                symbolSize: 4,
                trailLength: 0,
            },
            lineStyle: {
                normal: {
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                        offset: 0, color: '#58B3CC'
                    }, {
                        offset: 1, color: '#F58158'
                    }], false),
                    width: 2,
                    opacity: 0.5,
                    curveness: 0.1
                }
            },
            data: allData.moveLines
        }]
    };
}
mapOptionCalc();
var chinaDiv = echarts.init(document.getElementById('chinaDiv'));
chinaDiv.setOption(option_china);
//  function setChinaMap(para) {
//      allData.citys=[];
//      console.log(para)
//      para.map.dot.forEach(function (val,index) {
//            var city={};
//            city.name=val.name;
//            city.value=val.value;
//            city.symbolSize= val.symbolSize;
//            city.itemStyle= {normal: {color: "#F58158"}};
//            allData.citys.push(city)
//      })
//      allData.moveLines=[];
//      para.map.moveLines.forEach(function (val, index) {
//          allData.moveLines.push(val)
//      })
//      mapOptionCalc();
//      var chinaDiv = echarts.init(document.getElementById('chinaDiv'));
//      chinaDiv.setOption(option_china);
//  }



// 分时段车流量分析
// var tpl = `  <li  soda-repeat="item in list" >
//                        <div class="ico">{{$index+1}}</div>
//                        <div class="name">{{item.name}}</div>
//                        <div class="num">{{item.num}}</div>
//                    </li>`;
// // top10客源地城市静态数据
// var data = {list:[
//     {name: "河南",num: 666},
//     {name: "河南",num: 666},
//     {name: "河南",num: 666},
//     {name: "河南",num: 666},
//     {name: "河南",num: 666},
//     {name: "河南",num: 666},
//     {name: "河南",num: 666},
//     {name: "河南",num: 666},
//     {name: "河南",num: 666}
// ]}
// document.getElementById("city1").innerHTML = soda(tpl, data);
// document.getElementById("city2").innerHTML = soda(tpl, data);

// function setProvince(para) {
//    var data={};
//    data.list=para.province;
//     document.getElementById("city1").innerHTML = soda(tpl, data);
// }
// function setCity(para) {
//     var data = {};
//     data.list = para.city;
//     document.getElementById("city2").innerHTML = soda(tpl, data);
// }


// function regionSearch(t1, t2) {
//     var opt = {
//         type: 'get',
//         url: '/bigdata/manage/portrait/region',
//         data: {},
//         callback: function (res) {
//             if (res.code == 1) {
//                 dyw.box.alert(res.msg);
//                 return false
//             }
//             $("#date1").val(res.result.start_time);
//             setChinaMap(res.result)
//             setProvince(res.result)
//             setCity(res.result)
//         }
//     }
//     if (t1) {
//         opt.data = {
//             start_time: t1,
//             end_time: t2
//         }
//     }
//     loadData(opt)
// }
// regionSearch();
// $("#search1").on('click', function () {
//     var t1 = $("#date1").val();
//     var t2 = $("#date1").val();
//     if (!t1) {
//         dyw.box.alert('请选择查询时间');
//         return false
//     }
//     regionSearch(t1, t2);
// })



